﻿using System;
using UnityEngine;

// Token: 0x020000A2 RID: 162
[ExecuteInEditMode]
public class RenderTextureSetter : MonoBehaviour
{
	// Token: 0x06000523 RID: 1315 RVA: 0x0001E684 File Offset: 0x0001C884
	private void OnEnable()
	{
		this.camera = base.GetComponent<Camera>();
		this.rendTex = new RenderTexture(Screen.width, Screen.height, 0);
		this.camera.targetTexture = this.rendTex;
	}

	// Token: 0x06000524 RID: 1316 RVA: 0x0001E6BC File Offset: 0x0001C8BC
	private void OnDisable()
	{
		if (this.rendTex != null)
		{
			this.rendTex.Release();
			this.camera.targetTexture = null;
		}
	}

	// Token: 0x06000525 RID: 1317 RVA: 0x0001E6E8 File Offset: 0x0001C8E8
	public void LateUpdate()
	{
		if (this.rendTex.width != Screen.width || this.rendTex.height != Screen.height)
		{
			this.rendTex.Release();
			RenderTextureFormat format = (!this.camera.allowHDR) ? RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR;
			this.rendTex = new RenderTexture(Screen.width, Screen.height, 0, format);
			this.camera.targetTexture = this.rendTex;
		}
	}

	// Token: 0x06000526 RID: 1318 RVA: 0x0001E76C File Offset: 0x0001C96C
	public void RendTex(Material mat, string depthNormalTexName)
	{
		mat.SetTexture(depthNormalTexName, this.rendTex);
	}

	// Token: 0x0400041B RID: 1051
	private RenderTexture rendTex;

	// Token: 0x0400041C RID: 1052
	private Camera camera;
}
